/*****************************************************************************/
/**
 *  @file   main.cpp
 *  @author Naohisa Sakamoto
 */
/*----------------------------------------------------------------------------
 *
 *  Copyright (c) Visualization Laboratory, Kyoto University.
 *  All rights reserved.
 *  See http://www.viz.media.kyoto-u.ac.jp/kvs/copyright/ for details.
 *
 *  $Id$
 */
/*****************************************************************************/
#include <iostream>
#include <string>
#include <util/SPHFile.h>
#include <util/ImportSPHFile.h>
#include <util/ImportStaggeredSPHFile.h>
#include <kvs/AVSField>
#include <kvs/KVSMLObjectStructuredVolume>
#include <kvs/StructuredVolumeExporter>

void WriteAVSField( const std::string& filename, const kvs::StructuredVolumeObject& volume )
{
    typedef kvs::AVSField Format;

    Format* format = new kvs::StructuredVolumeExporter<Format>( &volume );
    format->write( filename );
    delete format;
}

void WriteKVSML( const std::string& filename, const kvs::StructuredVolumeObject& volume )
{
    typedef kvs::KVSMLObjectStructuredVolume Format;

    Format* format = new kvs::StructuredVolumeExporter<Format>( &volume );
    format->write( filename );
    delete format;
}

int main( int argc, char** argv )
{
    std::string filename( argv[1] );
    kvsbloodvis::util::SPHFile sph( filename );
    sph.print( std::cout );

//    kvs::StructuredVolumeObject volume = kvsbloodvis::util::ImportSPHFile( sph );
    kvs::StructuredVolumeObject volume = kvsbloodvis::util::ImportStaggeredSPHFile( sph );
    volume.print( std::cout );

    ::WriteAVSField( "output.fld", volume );
//    ::WriteKVSML( "output.kvsml", volume );

    return 0;
}
